#include "LocalResourceHTCell.h"
//necessary
#include "memory-tools.h"
#include "main-tools.h"

//TODO testing
PlocalResourceHTCell initLocalResourceHTCell(PlocalResourceElement _plocalresource){
	PlocalResourceHTCell result=(PlocalResourceHTCell)mallocMemory(sizeof(LocalResourceHTCell),"LocalResourceHTCell.c:initLocalResource:1");
	result->key=_plocalresource->name;
	result->localResource=_plocalresource;
	return result;
}

//TODO testing
void freeLocalResourceHTCell(PlocalResourceHTCell pcell){
	freeLocalResourceElement(pcell->localResource);
	freeMemory(sizeof(LocalResourceHTCell),pcell);
}

//TODO testing
void printLocalResourceHTCell(FILE* f,PlocalResourceHTCell pcell){
	fprintf(f,"[%s -> ",pcell->key);
	printLocalResourceElement(f,pcell->localResource);
	fprintf(f,"]");
}

//TODO testing
void generateDOTLocalResourceHTCell(FILE* f,PlocalResourceHTCell pcell,int* nodenumber,int* cellnumber,int format){
	printTabs(f,format);
	fprintf(f,"n%04d [shape=\"record\", label=\"{%s|",*nodenumber,pcell->key);
	generateDOTLocalResourceElement(f,pcell->localResource,nodenumber,cellnumber,format);
	fprintf(f,"}\"];\n");
	*cellnumber=*nodenumber;
	*nodenumber=*nodenumber+1;
}
